import { z } from 'zod'
import dotenv from 'dotenv'

dotenv.config()

const envSchema = z.object({
    PORT: z.string().default("5000"),
    UPLOAD_PATH: z.string().default("public/uploads"),
    HOST: z.string().default("localhost"),
    HTML_PATH: z.string().default("public/html"),
    DB_HOST: z.string().default("localhost"),
    DB_PORT: z.string().default("3306"),
    DB_USERNAME: z.string().default("root"),
    DB_PASSWORD: z.string(),
    DB_DATABASE: z.string(),
    MP_WEIXIN_APP_ID: z.string(),
    MP_WEIXIN_APP_SECRET: z.string(),
    SMS_ACCESS_KEY_ID: z.string(),
    SMS_SECRET_ACCESS_KEY: z.string(),
    REDIS_HOST: z.string(),
    REDIS_PORT: z.string(),
    REDIS_PASSWORD: z.string(),
    REDIS_DB: z.string(),
    REDIS_USER: z.string(),
    DB_ENTITIES: z.string(),
    // 微信支付相关配置
    WX_PAY_MCH_ID: z.string().optional(),
    WX_PAY_MCH_KEY: z.string().optional(),
    WX_PAY_NOTIFY_URL: z.string().optional(),
})

// 验证环境变量
const env = envSchema.parse(process.env)

export default env